package com.example.wan1.view.home;

import com.example.wan1.R;
import com.example.wan1.adapter.ArticleListAdapter;
import com.example.wan1.adapter.ProjectListAdapter;
import com.example.wan1.base.adapter.SubPagerAdapter;
import com.example.wan1.constant.Constants;
import com.example.wan1.di.ano.FragmentScope;
import com.example.wan1.model.ArticleBean;
import com.example.wan1.view.project.ProjectContract;

import java.util.ArrayList;
import java.util.List;

import androidx.fragment.app.Fragment;
import dagger.Binds;
import dagger.Module;
import dagger.Provides;

import static androidx.fragment.app.FragmentStatePagerAdapter.BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT;

/***
 * @Author: zxd
 * @CreateDate: 2020/8/26 14:07
 * @Description:
 */
@Module
public abstract class HomeModule {

    //首页
    @FragmentScope
    @Provides
    static SubPagerAdapter provideAdapter(HomeFragment home) {
        return new SubPagerAdapter(home.getChildFragmentManager(),
                BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT);
    }

    @FragmentScope
    @Provides
    static List<String> provideTitleList() {
        return new ArrayList<>();
    }

    @FragmentScope
    @Provides
    static List<Fragment> provideFragmentList() {
        return new ArrayList<>();
    }

    //最新文章
    @Binds
    abstract ArticleContract.View articleView(ArticleFragment articleFragment);

    @FragmentScope
    @Provides
    static ArticleListAdapter provideArticleAdapter(List<ArticleBean> list) {
        return new ArticleListAdapter(R.layout.article_item, list);
    }

    @FragmentScope
    @Provides
    static List<ArticleBean> provideArticleList() {
        return new ArrayList<>();
    }

    //最新项目
    @Binds
    abstract ProjectContract.View projectView(PerProjectFragment perProjectFragment);

    @FragmentScope
    @Provides
    static ProjectListAdapter provideProjectAdapter(List<ArticleBean> list, PerProjectFragment project) {
        return new ProjectListAdapter(R.layout.project_list_item, list,
                project.getArguments().getString(Constants.PROJECT_TYPE_PARAM));
    }

}
